import * as api from '../../service/api'
const state = {

  	deviceList : [],
}

const getters = {
	deviceList : state => state.deviceList,
}

const actions = {

	async updateDevice ({ commit }, para) {
		let res = await api.updateDevice(
			para.id,
			para.code,
			para.pas,
			para.view,
			para.remarks,
		);
		console.log(res);
		if(res.errcode === 0){
			if(para.cb){
				para.cb(res.data);
			}
		}else{
			if(para.err){
				para.err(res.errmsg);
			}
		}
	},
}

const mutations = {
	setDeviceList (state, obj) {
        state.deviceList = obj;
    },
}

export default {
  state,
  getters,
  actions,
  mutations
}
